const BasePlugin = require('./base-plugin');

class CommandPlugin extends BasePlugin {
    constructor() {
        super();
        this.name = '指令插件';
        this.author = '系统';
        this.priority = 5; // 高优先级
    }

    onPrivateMessage(event, reply) {
        const msg = event.raw_message.trim();

        switch (msg) {
            case '帮助':
                reply(this.getHelpText());
                return true;
                
            case '状态':
                reply(`🤖 状态正常\n运行时间: ${Math.floor(process.uptime())}秒`);
                return true;
                
            case 'ping':
                reply('pong 🏓');
                return true;
        }

        return false;
    }

    onGroupMessage(event, reply) {
        const msg = event.raw_message.trim();

        switch (msg) {
            case '帮助':
                reply('群聊可用命令：帮助、状态、ping');
                return true;
                
            case '状态':
                reply('✅ 机器人运行正常');
                return true;
                
                case 'ping':
                reply('✅ 网络正常');
                return true;
        }

        return false;
    }

    getHelpText() {
        return `🤖 机器人帮助
私聊命令：
• 帮助 - 显示此帮助
• 状态 - 查看状态
• 时间 - 显示时间
• ping - 测试响应`;
    }
}

module.exports = CommandPlugin;